<?php
require_once '../models/Product.php';

$action = $_REQUEST['action'];
if ($action == "add-brand"){
	$brandName = $_REQUEST['brandName'];
	$image = $_REQUEST['image'];
	$check = Product::checkBrand($brandName);
	if ($check == true){
		$re = Product::insertBrand($brandName,$image);
		if ($re){
			print('<span class="ok">Brand is successfully inserted.<a href="ql_model.php">Click Add new model</a></span>');
		}
		else print('<span class="error">System is busy. Please try again later.</span>');	
	}
	else print ('<span class="warning">This Brand is already in use.</span>');
	echo  Product::printBrandTable('');
}
if ($action == "up-brand"){
	$brandID= $_REQUEST['brandID'];
	$brandName =$_REQUEST['brandName'];
	$image=$_REQUEST['image'];
	$br_status=$_REQUEST['br_status'];
	$re=Product::updateBrand($brandID,$brandName,$image,$br_status);
	if($re){
		print('<span class="ok">Brand is successfully updated.</span>');
		

	}else $mgs="Cập nhật thất bại !!!";

}
?>